package gov.kqqzyyy.monkey.orderpad.dialogFragment;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import java.util.List;

import gov.kqqzyyy.monkey.orderpad.R;
import gov.kqqzyyy.monkey.orderpad.mytools.MyBaseActivity;
import gov.kqqzyyy.monkey.orderpad.ui.NavigationBaseActivity;
import gov.kqqzyyy.monkey.orderpad.ui.OrderCheckActivity2;
import gov.kqqzyyy.monkey.orderpad.ui.OrderMenuActivity;

/**
 * Created by Monkey on 2017/12/22.
 * 楼层切换对话框
 */

public class BuildingChangeDialog extends DialogFragment {

    private int defaultChoose = 0;

    public void setDefaultChoose(int defaultChoose) {
        this.defaultChoose = defaultChoose;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        String[] valueItems = getActivity().getResources().getStringArray(R.array.building_nums);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle("选择住院楼");
        builder.setSingleChoiceItems(R.array.building_names, defaultChoose, (dialog, which) -> {
            int chooseBuilding = Integer.valueOf(valueItems[which]);
            ((MyBaseActivity) getActivity()).getMySharedPreferences().edit().putInt("BUILD_NUM", chooseBuilding+1).apply();
            dismiss();
        });
        return builder.create();
    }

}
